# -*- coding: utf-8 -*-

import wx

class OpenFileDialog(wx.Dialog):
	def __init__(self, parent):
		wx.Dialog.__init__(self, parent, -1, 'Open File As...', size=(300, 120))
		panel = wx.Panel(self, -1)
		
		# Coding
		codingST = wx.StaticText(self, -1,
									   u"Character Code: ",
									   size=(90, -1)
									   )
		self.codingCB = wx.ComboBox(self, -1, 'utf_8',
								   choices = ('utf_8', 'shift_jis', 'euc_jp'),
								   size = (50, -1),
								   style = wx.CB_DROPDOWN
								   )
		codingSizer = wx.BoxSizer(wx.HORIZONTAL)
		space = 8
		codingSizer.Add(codingST, 0, wx.ALIGN_RIGHT|wx.RIGHT, space)
		codingSizer.Add(self.codingCB, 1, wx.EXPAND|wx.RIGHT, space)
		
		# Button
		openB = wx.Button(self, -1, "Open",
								   size=(60,25))
		cancelB = wx.Button(self, -1, "Cancel",
								   size=(60,25))
		self.Bind(wx.EVT_BUTTON, self.OnOpen, openB)
		self.Bind(wx.EVT_BUTTON, self.OnCancel, cancelB)
		buttonsSizer = wx.BoxSizer(wx.VERTICAL)
		buttonsSizer.Add(openB, 0)
		buttonsSizer.Add(cancelB, 0)
		
		# Sizer
		mainSizer = wx.BoxSizer(wx.HORIZONTAL)
		mainSizer.Add(codingSizer, 1, wx.ALL, space)
		mainSizer.Add(buttonsSizer, 0, wx.TOP|wx.BOTTOM|wx.RIGHT, space)
		self.SetSizer(mainSizer)
		
	def OnOpen(self, event):
		self.coding = self.codingCB.GetValue()
		self.EndModal(wx.ID_OK)
		
	def OnCancel(self, event):
		self.EndModal(wx.ID_CANCEL)
